﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using CarsModel;
using CarsBll;
namespace SencondHandCarBuyAndSell1._0.Controllers
{
    public class HomeController : ApiController
    {
        UsersBll bll = new UsersBll();
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="UsersNameorTel">用户电话</param>
        /// <param name="UsersPwd">用户密码</param>
        /// <returns></returns>
        public string GetUsersRegist(string UsersNameorTel, string UsersPwd)
        {
            string i = bll.UsersRegist(UsersNameorTel, UsersPwd);
            return i;
        }
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="UsersNameorTel">用户电话或用户名</param>
        /// <param name="UsersPwd">用户密码</param>
        /// <returns></returns>
        public int GetUsersLogin(string UsersNameorTel, string UsersPwd)
        {
            int i = bll.Login(UsersNameorTel, UsersPwd);
            return i;
        }

        /// <summary>
        /// 用户完善信息
        /// </summary>
        /// <param name="UsersModel"></param>
        /// <returns></returns>
        [HttpPost]
        public string GetUsersUpdate([FromBody]Users UsersModel)
        {
            return bll.UsersInfoUpdate(UsersModel);
        }
        /// <summary>
        /// 用户安全退出
        /// </summary>
        /// <param name="UsersID">当前用户ID</param>
        /// <returns></returns>
        public string GetUsersExit(int UsersID)
        {
            int  i = bll.UsersExit(UsersID);
            if (i > 0)
            {
                return "退出成功";
            }
            else
            {
                return "退出失败，请联系管理员";
            }
        }

    }
}
